#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e3+10,mod=1e9+7;
int n,k,L[N],a[N],dp[N][N],num[N][N];
string s,sl,sr;
inline int work(int x){
	memset(dp,0,sizeof(dp));
	dp[n][0]=L[n-1],num[n][0]=1;
	for(int i=n-1;i>=1;i--)
		for(int j=0;j<=k;j++){
			dp[i][j]=dp[i+1][j]+num[i+1][j]*L[n-i-1]*((k-j+x)%2!=a[i])%mod;
			if(j>0) dp[i][j]+=dp[i+1][j-1]+num[i+1][j-1]*L[n-i-1]*((k-j+x)%2==a[i])%mod;
			dp[i][j]%=mod;
			num[i][j]=num[i+1][j];
			if(j>0) num[i][j]+=num[i+1][j-1];
			num[i][j]%=mod;
		}
	int res=dp[1][k],rev=0,now=0;
	for(int i=1;i<n;i++){
		if(sl[i]=='1'){
			int rev1=rev;
			if((a[i]+x+rev)%2!=0) rev1++;
			if(rev1<=k) res-=now*num[i+1][k-rev1]%mod+dp[i+1][k-rev1],res=(res%mod+mod)%mod;
		}
		now+=(sl[i]-'0')*L[n-i-1]%mod,now%=mod;
		if(sl[i]-'0'!=(a[i]+x+rev)%2) rev++;
	}
	rev=0,now=0;
	for(int i=1;i<n;i++){
		if(sr[i]=='0'){
			int now1=(now+L[n-i-1])%mod,rev1=rev;
			if((a[i]+x+rev)%2!=1) rev1++;
			if(rev1<=k) res-=now1*num[i+1][k-rev1]%mod+dp[i+1][k-rev1],res=(res%mod+mod)%mod;
		}
		now+=(sr[i]-'0')*L[n-i-1]%mod,now%=mod;
		if(sr[i]-'0'!=(a[i]+x+rev)%2) rev++;
	}
	return res;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	cin>>n>>k>>s>>sl>>sr;
	s=" "+s;
	for(int i=1;i<n;i++)
		if(s[i]=='R') a[i]=1;
	L[0]=1;
	for(int i=1;i<=1000;i++)
		L[i]=L[i-1]*2%mod;
	cout<<(work(0)+work(1))%mod;
	return 0;
}
